 <?
	$group = $dsfm_common->get_all("common_group");
	$tpl->assign("group", $group);

	$all_assessment = $dsfm_common->get_all("assessment", "year=".$_SESSION['year']. " ORDER by sub ASC");
	$tpl->assign("all_assessment", $all_assessment);

	$all_standard = $dsfm_common->get_all("assessment_standard", "1 ORDER by id ASC");
	$tpl->assign("all_standard", $all_standard);

	$all_file = $dsfm_common->get_all("assessment_file");
	$tpl->assign("all_file", $all_file);

	switch($id) {
		case 1 : $tpl->draw("report1"); break;
		case 2 : $tpl->draw("report2"); break;
		case 3 : $tpl->draw("report3"); break;
		case 4 : $tpl->draw("report4"); break;
		case 5 : 
				for($i = 0; $i < 3; $i++){
					$year_range[$i]['year'] = $_SESSION['year']-1+$i;
					$year_range[$i]['grand_total'] = 0;

					$all_assessment = $dsfm_common->get_all("assessment", "year=".$year_range[$i]['year']. " ORDER by sub ASC");

					$tmp = array();

					foreach($group as $key => $value){
						foreach($all_assessment as $k => $v){
							if($v['gid'] == $value['id']){
								$tmp[$v['gid']] += $v['evaluation'];
								$year_range[$i]['grand_total'] += $v['evaluation'];
							}
						}
					}
					$year_range[$i]['total'] = $tmp;
				}

				$tpl->assign("year_range", $year_range);
				$tpl->draw("report5"); 
			break;
	}
	
?>